package com.fpt.mockproject.j21.absd.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "POSTCODE")
@DynamicUpdate(value = true)
public class PostCode {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "PostcodeID", nullable = false, updatable = false, unique = true)
	private Long postCodeID;
	
	@NaturalId
	@Column(name = "Postcode", nullable = false, unique = true)
	private String postCode;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "CountryID")
	private Country country;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "CountyID")
	private County county;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "TownID")
	private Town town;
	
	public Country getCountry() {
		return country;
	}
	public void setCountry(Country country) {
		this.country = country;
	}
	public County getCounty() {
		return county;
	}
	public void setCounty(County county) {
		this.county = county;
	}
	public Town getTown() {
		return town;
	}
	public void setTown(Town town) {
		this.town = town;
	}
	public Long getPostCodeID() {
		return postCodeID;
	}
	public void setPostCodeID(Long postCodeID) {
		this.postCodeID = postCodeID;
	}
	public String getPostCode() {
		return postCode;
	}
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}
}
